﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClearingRestartingAutomaton.Common
{
    /// <summary>
    /// Length-lexicographical comparer for strings.
    /// </summary>
    public class StringLengthLexComparer : IComparer<string>
    {
        /// <summary>
        /// Compares two strings based on length-lexicographical order and returns a value 
        /// indicating whether one is less than, equal to, or greater than the other.
        /// </summary>
        /// <param name="x">Left hand side string.</param>
        /// <param name="y">Right hand side string.</param>
        /// <returns>
        /// A 32-bit signed integer that indicates whether the left hand side string precedes, follows, 
        /// or appears in the same position in the length-lexicographical order as the right hand side string.
        /// Value Condition Less than zero: the left hand side string precedes the right hand side string. 
        /// Zero: the left hand side string has the same position in the sort order as the right hand side string. 
        /// Greater than zero: the left hand side string follows the right hand side string.
        /// </returns>
        public int Compare(string x, string y)
        {
            return x.LengthLexCompare(y);
        }
    }
}
